package top.api.service.impl;

import cn.dev33.satoken.stp.StpUtil;
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import org.springframework.beans.factory.annotation.Autowired;
import top.api.common.ResUlt;
import top.api.domain.dto.GroupInfoDto;
import top.api.domain.pojo.GroupInfo;
import top.api.service.GroupInfoService;
import top.api.mapper.GroupInfoMapper;
import org.springframework.stereotype.Service;
import top.api.utils.BeanCopyUtils;

import javax.servlet.http.HttpServletRequest;

/**
* @author 86191
* @description 针对表【group_info】的数据库操作Service实现
* @createDate 2024-05-29 09:11:30
*/
@Service
public class GroupInfoServiceImpl extends ServiceImpl<GroupInfoMapper, GroupInfo> implements GroupInfoService{

    @Autowired
    private GroupInfoMapper groupInfoMapper;


    //   保存群组信息
    @Override
    public ResUlt<?> saveGroupInfo( GroupInfoDto groupInfoDto) {
        LambdaQueryWrapper<GroupInfo> lqw = new LambdaQueryWrapper<>();
        lqw.eq(GroupInfo::getGroupId,groupInfoDto.getGroupId());
        if(groupInfoMapper.selectOne(lqw)!=null){
            return ResUlt.error("群组已存在");
        }
        groupInfoMapper.insert(BeanCopyUtils.copyBean(groupInfoDto, GroupInfo.class));
        return null;
    }
}




